package com.junlaninfo;

/**
 * Created by 辉 on 2020/7/29.
 * 演示join方法的使用
 */
public class Thread008 implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 20; i++) {
            System.out.println("当前线程是：" + Thread.currentThread().getName() + "当前数是:" + i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread008 thread008 = new Thread008();
        Thread t1 = new Thread(thread008, "t1");
        Thread t2= new Thread(thread008, "t1");
        Thread t3 = new Thread(thread008, "t1");
        //调用者都是当前线程，阻塞的都是当前线程
        t1.start();
        t1.join();
        t2.start();
        t2.join();
        t3.start();
        t3.join();
        for (int i = 0; i < 20; i++) {
            System.out.println("当前线程是：" + Thread.currentThread().getName() + "当前数是:" + i);
        }

    }
}
